using System;
using System.Diagnostics;

namespace MinecraftGPS.Data
{
    [DebuggerDisplay("Bearing {Bearing} : Pitch {Pitch}")]
    struct Direction
    {
        private readonly bool notEmpty;

        public Direction(float bearing, float pitch)
        {
            this.Bearing = (float)Math.IEEERemainder(bearing, 360);
            this.Pitch = pitch;
            this.notEmpty = true;
        }

        public readonly float Bearing;
        public readonly float Pitch;

        public bool IsEmpty { get { return !notEmpty; } }

        public override bool Equals(object obj)
        {
            if (!(obj is Direction))
                return false;

            Direction comparison = (Direction)obj;

            return comparison.Bearing.Equals(Bearing) && comparison.Pitch.Equals(Pitch);
        }

        public override int GetHashCode()
        {
            return this.Bearing.GetHashCode() ^ this.Pitch.GetHashCode();
        }
    }
}
